import { Link } from 'umi';
import { Space, Popconfirm } from 'antd';


const columns = (delAction) => {
  return [
    {
      title: '角色名称',
      key: 'name',
      dataIndex: 'name'
    },
    {
      title: '角色描述',
      key: 'describe',
      dataIndex: 'describe'
    },
    {
      title: '是否为内置',
      key: 'isInner',
      dataIndex: 'isInner',
      align: 'center',
      render: (text) => (<>{text ? '是' : '否'}</>)
    },
    {
      title: '创建时间',
      key: 'createTime',
      dataIndex: 'createTime',
      align: 'center',
      sorter: (a, b) => (new Date(a.createTime).getTime() - new Date(b.createTime).getTime())
    },
    {
      title: '操作',
      key: 'action',
      fixed: 'right',
      align: 'center',
      render: (text, row) => (
        <Space size="middle">
          <Link to={{ pathname: "/setting/role/detail", query: { id: row.roleId } }}>详情</Link>
          <Link to={{ pathname: "/setting/role/modify", query: { id: row.roleId } }}>修改</Link>
          <Popconfirm
            title={`您确定要删除角色 ${row.name} 吗？`}
            onConfirm={() => {delAction ? delAction(row.roleId) : null}}
            okText="确定"
            cancelText="取消">
            <a>删除</a>
          </Popconfirm>
        </Space>
      )
    }
  ]
} 

export default columns